import collections
class Solution(object):
    def countNicePairs(self, nums):
        def rev(x):
            return int(str(x)[::-1])
        new_num = [num - rev(num) for num in nums]
        c = collections.Counter(new_num)
        base = 10 ** 9 + 7
        now = 0
        for key in c:
            now += c[key] * (c[key] - 1) // 2
        return now % base
